<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>打印消费记录</title>
    <!-- 引入 Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
    <style>
        body {
            background-color: #f4f6f9;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .print-record-container {
            background-color: #fff;
            padding: 40px;
            border-radius: 8px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 800px;
        }
        .print-record-container h1 {
            text-align: center;
            margin-bottom: 30px;
            color: #333;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
    </style>
</head>
<body>
<div class="print-record-container">
    <h1>打印消费记录</h1>
    <form action="/springmvc02_ssm/printRecord" method="post">
        <div class="form-group">
            <label for="number">卡号</label>
            <input type="text" id="number" name="number" required>
        </div>
        <div class="form-group">
            <label for="mima">密码</label>
            <input type="password" id="mima" name="mima" required>
        </div>
        <button type="submit" class="btn btn-primary">查询记录</button>
    </form>
    <c:if test="${not empty records}">
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <th>消费类型</th>
                <th>使用量</th>
                <th>扣费金额</th>
                <th>消费时间</th>
                <th>备注</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="record" items="${records}">
                <tr>
                    <td>${record.consumption_type}</td>
                    <td>${record.quantity}</td>
                    <td>${record.amount}</td>
                    <td><fmt:formatDate value="${record.consumption_time}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                    <td>${record.remark}</td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </c:if>
    <c:if test="${empty records and param.submit != null}">
        <p class="text-danger">无消费记录</p>
    </c:if>
</div>
<!-- 引入 Bootstrap JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</body>
</html>